<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li>师恩难忘</li>
    </ul>
    <input class="teachername"/>
    <button class="btn">吾师</button>
    <script>
        var ulEle = document.querySelector("ul");
        var inpEle = document.querySelector(".teachername");
        var btnEle = document.querySelector(".btn");
        // 第一步 获取想要操作的元素

        // 第二步 绑定点击事件

        btnEle.onclick = function(){
            // .onclick之前的名字必须和之前变量名一致
            var teachername = `<li>${inpEle.value}<li/>`;
               ulEle.innerHTML += teachername; 
        } 

    </script>

<!-- 
    <ul>
        <li>学分榜</li>
        
    </ul>
    <input class="username"/>
        <button class="btn">添加</button>
    <script>
        var ulEle = document.querySelector("ul");
        var inpEle = document.querySelector(".username");
        var btnEle = document.querySelector(".btn");

        //绑定点击事件
        btnEle.onclick = function(){
            var username = `<li>${inpEle.value}</li>`;  //在这个位置如果<li>的结束标签错写成了<li/>,最终显示结果会多出一个点。
            ulEle.innerHTML += username; 
        }
    </script> -->



    
</body>
</html>